#include "stdafx.h"
#include "TestZonePersist.h"
#include "ZonePersist.h"
#include "Zone.h"
#include "DatabaseBase.h"
#include "UEConnectionManager.h"

using namespace PDMS::PDMSDBIF;
using namespace PDMS::PDMSDomain;
CPPUNIT_TEST_SUITE_REGISTRATION( TestZonePersist );


TestZonePersist::TestZonePersist()
{
}


TestZonePersist::~TestZonePersist()
{
}

void TestZonePersist::testCreate()
{
	DatabaseBase DB( GET_REGISTER( DatabaseElementFactory, Design_VersionOne ) );
	DB.DataSource( _T( "D:\\DesignDBTemplate.mdb" ) );
	UEConnectionPtr ptr = DB.DataSource();

	ZonePersist SP;
	SP.SetDatabase( &DB );

	Zone *pZone = new Zone;
	pZone->SetArea( 3 );
	pZone->SetNumber( 6 );
	pZone->SetFunction( _T("9") );

	UESoft::ErrorStatus es = SP.Create( pZone );
	ASSERT( es == UESoft::eOk );
	
	delete pZone;
	CPPUNIT_ASSERT( ptr != NULL );
	UEConnectionManager::Instance().CloseAllConnection();
}

void TestZonePersist::testUpdate()
{
	DatabaseBase DB( GET_REGISTER( DatabaseElementFactory, Design_VersionOne ) );
	DB.DataSource( _T( "D:\\DesignDBTemplate.mdb" ) );
	UEConnectionPtr ptr = DB.DataSource();

	ZonePersist SP;
	SP.SetDatabase( &DB );

	Zone *pZone = new Zone;
	pZone->SetArea( 3 );
	pZone->SetNumber( 6 );
	pZone->SetFunction( _T("9") );

	UESoft::ErrorStatus es = SP.Update( pZone );
	ASSERT( es == UESoft::eOk );
	
	delete pZone;
	CPPUNIT_ASSERT( ptr != NULL );
	UEConnectionManager::Instance().CloseAllConnection();
}

void TestZonePersist::testRetrieve()
{

}
